<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="ntModalLabel">货柜状态更改</h4>
</div>
<form class="modal-body" id="formbox">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="alert alert-dismissable alert-info">
                <button type="button" class="close">×</button>
                <p></p>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
            设置
        </div>
        <div class="col-md-3">
            <select class="form-control" name="num">
                <option value="1">{:lang("preparation_date")}</option>
                <option value="2">{:lang("sailing_date")}</option>
                <option value="3">{:lang("arrived_at_the_port")}日期</option>
                <option value="4">入仓日期</option>
            </select>
        </div>
        <div class="col-md-7">
            <div class="input-group date form_datetime" data-link-field="etd_day">
                <input class="form-control" type="text" name="time" value="">
                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" style="margin:0"></span></span>
            </div>
            <input type="hidden" id="etd_day" value="" />
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover ntTable">
                <thead>
                <tr>
                    <td>{:strtoupper(lang('container_ID'))} / {:strtoupper(lang('name'))}</td>
                    <td>{:strtoupper(lang('preparation_date'))}</td>
                    <td>{:strtoupper(lang('sailing_date'))}</td>
                    <td>{:strtoupper(lang('arrived_at_the_port'))}日期</td>
                    <td>入仓日期</td>
                </tr>
                </thead>
                <tbody>
                {volist name="resdata.data" id="vo"}
                <tr>
                    <td>{$vo.id|default=''} / {$vo.name|default=''}</td>
                    <td>{$vo.ready_day==0?'-':$vo.ready_day}</td>
                    <td>{$vo.etd_day==0?'-':$vo.etd_day}</td>
                    <td>{$vo.eta_day==0?'-':$vo.eta_day}</td>
                    <td>{$vo.arrival_day==0?'-':$vo.arrival_day}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <input type="hidden" name="id" value="{$ids|default=''}">
            <input type="hidden" name="name" value="{$resdata.name|default=''}">
        </div>
    </div>
</form>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>{:strtoupper(lang('cancel'))}</button>
    <button type="button" id="qudins" class="btn btn-primary" style="padding-left:24px;padding-right:24px"><span class="glyphicon glyphicon-floppy-disk"></span>{:strtoupper(lang('save'))}</button>
</div>
<script language="javascript">
    $(document).ready(function () {
        var lang = $('#lang').text();
        var language = '';
        if (lang == 'pt') {
            language = 'pt-BR';
        } else if (lang == 'en') {
            language = 'en';
        } else {
            language = 'zh-CN';
        }
        $('.form_datetime').datetimepicker({
            language: language, // en ,zh-CN, pt-BR
            format: 'yyyy-mm-dd',
            minView: 'month',
            weekStart: 0, //一周从哪一天开始
            todayBtn: 1, //底部会出现一个今天
            autoclose: true,//自动关闭
            todayHighlight: 1,//高亮今天日期
            startView: 2,//显示的视图
            forceParse: 1,//当选择器关闭的时候，是否强制解析输入框中的值
            showMeridian: 1
        });
    });
    //处理数据的写入
    $('#qudins').click(function () {
        subfn()
    })
    var addbm = true;
    function subfn() {
        if (addbm) {
            $.ajax({
                url: '/Admin/logistics/containerchang',
                type: 'post',
                data: $("#formbox").serialize(),
                dataType: 'json',
                success: function (res) {
                    if (res.status != 1) {
                        change_mes_type('.modal-body .alert',res.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+res.msg+'<br>')
                    } else {
                        change_mes_type('#headeralert',res.status)
                        addbm = false
                        $('#headeralert').show()
                        $('#headeralert p').html('*'+res.msg+'<br>')
                        $('#container_batModal').modal('hide')
                    }
                }
            });
        }
    }
    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            $('form').each(function () {
                event.preventDefault();
            });
            subfn()
        }
    });
</script>